﻿--5 - Найти всех мам

select [LastName], [Name]
from [MyFamily].[dbo].[Persons] as E1
where EXISTS(
select *
from [MyFamily].[dbo].[Persons] as E2
where E1.ID = E2.fk_motherID);

SELECT DISTINCT A1.[LastName], A1.[Name]
from [MyFamily].[dbo].[Persons] as A1, [MyFamily].[dbo].[Persons] as A2
where (A1.ID = A2.fk_motherID)

select distinct [LastName], [Name]  from [MyFamily].[dbo].[Persons] where [ID]
 in (select [fk_motherID] from [MyFamily].[dbo].[Persons] where [fk_motherID] is NOT NULL)